aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/funds/[id]/withdraw/+page.server.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-11-09 16:49:10 -0800
committerAdam Soltys <[email protected]>2023-11-11 00:04:22 -0800
commitefdbc67c17fab67bf3cdce448a30aa82f62c5212 (patch)
tree8af4f6245ea63e0b8a2d36f5da88439fc8d38ff7 /src/routes/(app)/funds/[id]/withdraw/+page.server.js
parent9d554851a47ca9b4efd38f2682f313bd2623f8bf (diff)
downloadcoinos-ui-efdbc67c17fab67bf3cdce448a30aa82f62c5212.tar.gz
coinos-ui-efdbc67c17fab67bf3cdce448a30aa82f62c5212.zip
funds
Diffstat (limited to 'src/routes/(app)/funds/[id]/withdraw/+page.server.js')
-rw-r--r--src/routes/(app)/funds/[id]/withdraw/+page.server.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/routes/(app)/funds/[id]/withdraw/+page.server.js b/src/routes/(app)/funds/[id]/withdraw/+page.server.js
new file mode 100644
index 00000000..476149f2
--- /dev/null
+++ b/src/routes/(app)/funds/[id]/withdraw/+page.server.js
@@ -0,0 +1,20 @@
+import { fail, json, redirect } from '@sveltejs/kit';
+import { fd, auth, post } from '$lib/utils';
+
+export async function load({ parent }) {
+ let { user } = await parent();
+ if (!user) throw redirect(307, '/register');
+}
+
+export const actions = {
+ default: async ({ cookies, request }) => {
+ let body = await fd(request);
+ try {
+ await post('/take', body, auth(cookies));
+ } catch (e) {
+ return fail(400, { message: e.message });
+ }
+
+ throw redirect(307, `/fund/${body.id}`);
+ }
+};